﻿<!--
 Peter
 Created by: Peter Development Team
    http://peter.codeplex.com/
 
 GNU General Public License version 2 (GPLv2)
    http://peter.codeplex.com/license
-->
<UserControl x:Class="Peter.View.ViewOpenProject"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
             xmlns:controls="clr-namespace:Peter.Common.Controls;assembly=Peter.Common"
             xmlns:icons="clr-namespace:Peter.Common.Icons;assembly=Peter.Common"
             mc:Ignorable="d" 
             d:DesignHeight="300" d:DesignWidth="300">
   <Grid>
      <Grid.Resources>
         <CollectionViewSource x:Key="_Projects"
                               Source="{Binding Path=ProjectManager.ProjectTypes}">
            <CollectionViewSource.GroupDescriptions>
               <PropertyGroupDescription PropertyName="ProjectGroup" />
            </CollectionViewSource.GroupDescriptions>
         </CollectionViewSource>
      </Grid.Resources>
      
      <Grid.RowDefinitions>
         <RowDefinition Height="Auto" />
         <RowDefinition Height="*" />
         <RowDefinition Height="*" />
         <RowDefinition Height="Auto" />
      </Grid.RowDefinitions>

      <TextBlock Grid.Row="0"
                 FontWeight="Bold"
                 FontSize="22"
                 FontFamily="Trebuchet MS"
                 VerticalAlignment="Center"
                 Text="Open a Project:" />

      <ListBox ItemsSource="{Binding Source={StaticResource _Projects}}"
               SelectedItem="{Binding Path=SelectedItem}"
               Grid.Row="1">
         <ListBox.GroupStyle>
            <GroupStyle>
               <GroupStyle.ContainerStyle>
                  <Style TargetType="{x:Type GroupItem}">
                     <Setter Property="Template">
                        <Setter.Value>
                           <ControlTemplate>
                              <Expander Header="{Binding Name}"
                                        IsExpanded="True">
                                 <ItemsPresenter Margin="10,0,0,0" />
                              </Expander>
                           </ControlTemplate>
                        </Setter.Value>
                     </Setter>
                  </Style>
               </GroupStyle.ContainerStyle>
            </GroupStyle>
         </ListBox.GroupStyle>

         <ListBox.ItemTemplate>
            <DataTemplate>
               <StackPanel Orientation="Horizontal">
                  <icons:IconDisplay Icon="{Binding Path=Icon}" />
                  <TextBlock Text="{Binding Path=Name}"
                             Margin="4,0,0,0" />
               </StackPanel>
            </DataTemplate>
         </ListBox.ItemTemplate>
      </ListBox>

      <controls:Explorer Grid.Row="2"
                         Margin="0,10,0,0"
                         SelectedTreeItem="{Binding Path=SelectedLocation, Mode=TwoWay}">
         <controls:Explorer.ItemContainerStyle>
            <Style TargetType="{x:Type TreeViewItem}">
               <Setter Property="IsExpanded"
                       Value="{Binding IsExpanded, Mode=TwoWay}" />
               <Setter Property="IsSelected"
                       Value="{Binding IsSelected, Mode=TwoWay}" />
            </Style>
         </controls:Explorer.ItemContainerStyle>

         <controls:Explorer.Resources>

            <HierarchicalDataTemplate DataType="{x:Type controls:ExplorerItem}"
                                      ItemsSource="{Binding Path=Children}">
               <StackPanel Orientation="Horizontal"
                           VerticalAlignment="Center">
                  <icons:IconDisplay IconSize="Medium"
                                     Margin="0,0,3,0"
                                     Icon="{Binding Path=Icon}" />
                  <TextBlock Text="{Binding Path=Text}"
                             VerticalAlignment="Center"
                             Margin="0, 0, 5, 0" />
               </StackPanel>
            </HierarchicalDataTemplate>

         </controls:Explorer.Resources>
      </controls:Explorer>

      <Grid Grid.Row="3">
      </Grid>
   </Grid>
</UserControl>
